/*
 * Copyright (C) 2004-2009  Autodesk, Inc.
* 
* This library is free software; you can redistribute it and/or
* modify it under the terms of version 2.1 of the GNU Lesser
* General Public License as published by the Free Software Foundation.
* 
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
* 
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef MAPINFOFEATURESCHEMA_H_
#define MAPINFOFEATURESCHEMA_H_     1

#ifdef _WIN32
#pragma once
#endif

class MapInfoConnection;
class MapInfoFeatureSchemaCollection;
class MapInfoClassDefinition;
class MapInfoClassDefinitionCollection;

// A bridge between logical and physical schema for FdoFeatureSchema.
class MapInfoFeatureSchema
    : public FdoDisposable
{
public:
    MapInfoFeatureSchema(void); // 0-argument constructor to please FdoPtr::operator-> 

    MapInfoFeatureSchema(
        MapInfoConnection* conn,
        FdoFeatureSchema* fdoSchema);

    MapInfoFeatureSchema(
        MapInfoConnection* conn,
        FdoFeatureSchema* fdoSchema,
        MapInfoClassDefinitionCollection* mapinfoClasses);

    // For FdoNamedCollection:
    FdoString * GetName() const;
    bool CanSetName() const;

    FdoString* GetLocation();
    FdoFeatureSchema * GetFdoSchema() const;
    MapInfoClassDefinitionCollection* GetMapInfoClasses();

    void AddClass (IMapInfoFile* layer, FdoClassDefinition* fdoClassDef);
    // Create an MapInfoClassDefinition instance and add it into m_mapinfoClasses.
    void AddClass(FdoClassDefinition* fdoClassDef);
    void ModifyClass(FdoClassDefinition* fdoClassDef);
    void DeleteClass (MapInfoClassDefinition* mapinfoClassDef);
    void DeleteAllClasses();

protected:
    virtual ~MapInfoFeatureSchema(void);

private:
    FdoPtr<MapInfoConnection>                 m_connection;
    FdoPtr<FdoFeatureSchema>                  m_fdoSchema;
    FdoPtr<MapInfoClassDefinitionCollection>  m_mapinfoClasses;
};


class MapInfoFeatureSchemaCollection : public FdoNamedCollection<MapInfoFeatureSchema, FdoException>
{
public:
    MapInfoFeatureSchemaCollection(void);
    FdoFeatureSchemaCollection* GetFdoSchemas();
    virtual FdoInt32 Add( MapInfoFeatureSchema* value);

protected:
    // Destructor:
    virtual ~MapInfoFeatureSchemaCollection(void) {}

    /// <summary>Dispose this object instance.</summary>
    /// <returns>Returns nothing</returns>
    virtual void Dispose() 
    { 
        delete this; 
    }
};

typedef FdoPtr<MapInfoFeatureSchemaCollection> MapInfoLpFeatureSchemaCollectionP;


#endif // MAPINFOFEATURESCHEMA_H_

